// 引入Service和请求头ServiceName
import { Service, ServiceName } from '@/network/http.js'
import store from '@/store/index.js' // 引入store

const api = {
  /**
     * 获取船舶水电费
     * @param {Object} params 检索条件的obj
     */
  reqGetShipUseCost(params) {
    return Service.get(
      `/${ServiceName}/api/external/costWaterElectricity/queryall`,
      { params }
    )
  },
  /**
     * 查看结算
     * @param {String} id 航次id
     * @param {String} companyId 组织id{收款人id}
     */
  reqGetSettlement(id, companyId) {
    return Service.get(
      `/${ServiceName}/api/external/costWaterElectricity/queryById?id=${id}&companyId=${companyId}`
    )
  },
  /**
     * 结算
     */
  reqSaveList(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/costWaterElectricity/addCost`,
      params
    )
  },
  /**
     * 审核
     * @param {String} id {shipvoyageId=航次id}
     */
  reqExamineList(id) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/costWaterElectricity/verifyByShipvoyageId?shipvoyageId=${id}`
    )
  },
  /**
     * 撤销结算
     * @param {String} id {shipvoyageId=航次id}
     */
  reqRevokeList(id) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/costWaterElectricity/cancleByShipvoyageId?shipvoyageId=${id}`
    )
  },
  /**
     * 撤销审核
     * @param {String} id {shipvoyageId=航次id}
     */
  reqRevokeExamine(id) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/costWaterElectricity/revokeByShipvoyageId?shipvoyageId=${id}`
    )
  }
}
export default api
